<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main</title>
<jsp:include page="../head.jsp" />
<script type="text/javascript">

	function save(){
		
		
		if(trim($("#roleName").val())==""){
			addError("roleName","角色名称不能为空.");
			return;
		}
		if (!checkForm(document.getElementById("saveForm"))) {
			return;
		}
		if($("#chkCompay").prop("checked"))$("#allCompanyAuthorityFlag").val(1);
		if($("#chkDep").prop("checked"))$("#allDepAuthorityFlag").val(1);
		xbox.load("loading");	
		$("#saveForm").ajaxSubmit(function(){
	    	$("#refreshForm").submit();
	    });
	}
	function turnBack(){
	   $("#refreshForm").submit();
	}
	function openCompany(){
		$(".allOpenCompany").show();
	}
	function closeCompany(){
		$(".allOpenCompany").hide();
		$("#allCompanyAuthorityFlag").val(0);
		$("#chkCompany").prop("checked","");
	}
	function openDep(){
		$(".allOpenDep").show();
	}
	function closeDep(){
		$(".allOpenDep").hide();
		$("#allDepAuthorityFlag").val(0);
		$("#chkDep").prop("checked","");
	}
</script>

</head>
<body>
<form action="<%=path%>/role/role_save_listAction.action" method="post" id="saveForm">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr bgcolor="#FFFFFF">
    <td colspan="4" height="16"><span></span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>角色名称：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="text" name="role.roleName" id="roleName" value="${role.roleName}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">角色编号：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="text" name="role.roleNo" id="roleNo" value="${role.roleNo}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF" <c:if test="${DEVELOP_MODEL ne true}">style="display:none;"</c:if>>
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>公司级层级权限：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="radio" name="role.companyAuthorityFlag" value="1" id="openFlagYes" onclick="openCompany()"/>启用&nbsp;<input type="radio" value="0" name="role.companyAuthorityFlag" id="openFlagNo"  onclick="closeCompany()" checked="checked"/>禁用
    			<input class="allOpenCompany" type="checkbox" style="display:none;" id="chkCompany" title="开启后将可以看到下级公司产生的所有数据,默认关闭"/><span  style="display:none;" class="allOpenCompany">层级权限递归</span>
              <input type="hidden" name="role.allCompanyAuthorityFlag" id="allCompanyAuthorityFlag" value="0"/>
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">部门级层级权限：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input type="radio" name="role.depAuthorityFlag" value="1" id="openFlagYes" onclick="openDep()"/>启用&nbsp;<input type="radio" value="0" name="role.depAuthorityFlag" id="openFlagNo" checked="checked" onclick="closeDep()"/>禁用
              <input class="allOpenDep" type="checkbox" style="display:none;" id="chkDep" title="开启后将可以看到下级部门产生的所有数据,默认关闭"/><span  style="display:none;" class="allOpenDep">层级权限递归</span>
              <input type="hidden" name="role.allDepAuthorityFlag" id="allDepAuthorityFlag" value="0"/>
    </td>
  </tr>
  
  <tr bgcolor="#FFFFFF" <c:if test="${DEVELOP_MODEL ne true}">style="display:none;"</c:if>>
   	<td width="10%" align="right" bgcolor="#FFFFFF">所属公司：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
   	<select id="parentCompanyId" name="companyId">
    	<option value="1">默认设置</option>
    	<c:forEach items="${companyList}" var="com">
    	<option value="${com.companyId}"><c:out value="${com.companyName}" /></option>
    	</c:forEach>
   	</select>
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF">所属部门：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
   	<select id="parentDepartmentId" name="departmentId">
    	<option value="1">默认设置</option>
    	<c:forEach items="${departmentList}" var="dep">
    	<option value="${dep.departmentId}"><c:out value="${dep.departmentName}" /></option>
    	</c:forEach>
   	</select>
    </td>
    
   </tr>
   
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">备注：</td>
    <td width="90%" colspan="3" align="left" bgcolor="#FFFFFF">
    			<textarea rows="3"  name="role.remark" id="remark">${role.remark}</textarea>
    </td>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="4" align="center">
		<input type='button' class="btn btn-primary" id="btnSave" onclick="save();" value='保存' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>
</form>
<form action="${listUrl}" method="post" style="display: none;" id="refreshForm" name="refreshForm"/>
</body>
</html>
